﻿#include"Myset.h"
#include"Mymap.h"
void TestRBTree()
{
	zy::map<int, int> m;
	zy::set<int> s;
	// 常规的测试⽤例
	//int a[] = { 16, 3, 7, 11, 9, 26, 18, 14, 15 };
	// 特殊的带有双旋场景的测试⽤例
	int a[] = { 4, 2, 6, 1, 3, 5, 15, 7, 16, 14 };
	for (auto& e : a)
	{
		m.Insert({ e, e });
		s.Insert(e);
	}

	zy::set<int>::iterator sit = s.end();
	while (sit != s.begin())
	{
		--sit;
		//*sit += 5; 
		cout << *sit << " ";
	}
	for (auto& e : s)
	{
		cout << e << " ";
	}
	zy::map<int, int>::iterator mit = m.begin();
	while (mit != m.end())
	{
		cout << mit->first << ":" << mit->second << endl;
		++mit;
	}
}

void test_map()
{
	zy::map<string, string> dict;
	dict.Insert({ "sort", "排序" });
	dict.Insert({ "left", "左边" });
	dict.Insert({ "right", "右边" });
	dict["left"] = "左边，剩余";
	dict["insert"] = "插入";
	dict["string"];
	zy::map<string, string>::iterator it = dict.begin();
	while (it != dict.end())
	{
		// 不能修改first，可以修改second
		//it->first += 'x';
		it->second += 'x';
		cout << it->first << ":" << it->second << endl;
		++it;
	} 
	cout << endl;
}

int main()
{
	//TestRBTree();
	test_map();
	return 0;
}